home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’95
/
EssentialDoc
/
SB.p
< prev
next >
Wrap
Text File
|
1995-06-24
|
9KB
|
306 lines
program STS;
uses FSM,Dialogs,Fonts,Resources,Files,Script,CursorCtl,ToolUtils,QDOffscreen,LowMem;
const
SimpleTextName='Simple Text';
SimpleTextCrea='ttxt';
SimpleTextType='APPL';
type
PICTinfo=record
size:integer;
frame:rect;
end;
PICTinfoPtr=^PictInfo;
PICTinfoH=^PICTInfoPtr;
var
theVolume:integer;
theName:Str255;
theRefnum:integer;
theWindow:WindowPtr;
theGErr,err:OSErr;
theGSpec:FSSpec;
theErrorBox,theButtons,theGPF:PicHandle;
myRect,importRect:rect;
myGWorld: GWorldPtr;
lockFlag:boolean;
savePort: CGrafPtr;
saveDevice: GDHandle;
sButtonRect,dButtonRect:rect;
mloc:point;
ignoreBR,cancelBR:rect;
sitting,ignore,cancel:boolean;
dummy:longint;
theH:integer;
tempRgn,oldRgn:RgnHandle;
myWhite,myBlack:RGBColor;
Input:str255;
function GetIndVolume (whichVol: INTEGER; var volName: Str255; var volRefNum: INTEGER): OSErr;
{Return the name and vRefNum of volume specified by whichVol.}
var
volPB: HParamBlockRec;
error: OSErr;
begin
with volPB do
begin {makes it easier to fill in!}
ioNamePtr := @volName; {make sure it returns the name}
ioVRefNum := 0; {0 means use ioVolIndex}
ioVolIndex := whichVol; {use this to determine the volume}
end; {with}
error := PBHGetVInfo(@volPB, false); {do it}
if error = noErr then
begin {if no error occurred }
volRefNum := volPB.ioVRefNum; {return the volume reference}
end; {if no error}
{other information is available from this record; see the FILE}
{Manager's description of PBHGetVInfo for more details...}
GetIndVolume := error; {return error code}
end;
procedure DisplayWindow;
begin
theWindow := GetNewWindow(128, nil, WindowPtr(-1));
SetPort(theWindow);
ShowWindow(theWindow);
end;
PROCEDURE EnumerShell (vRefNumToSearch: Integer; { the vRefNum to search}
dirIDToSearch: LongInt); { the dirID to search }
VAR
itemName: Str63;
myCPB: CInfoPBRec;
err: OSErr;
PROCEDURE EnumerateCatalog (dirIDToSearch: LongInt);
CONST
ioDirFlgBit = 4;
VAR
index: Integer;
BEGIN { EnumerateCatalog }
index := 1;
REPEAT
WITH myCPB DO
BEGIN
ioFDirIndex := index;
ioDrDirID := dirIDToSearch; { we need to do this every }
{ time through }
filler2 := 0; { Clear the ioACUser byte if search is }
{ interested in it. Nonserver volumes }
{ won't clear it for you and the value }
{ returned is meaningless. }
END;
err := PBGetCatInfo(@myCPB, FALSE);
IF err = noErr THEN
IF BTST(myCPB.ioFlAttrib, ioDirFlgBit) THEN BEGIN { we have a directory }
{ do something useful with the directory information }
{ in myCPB }
{Here we blast the image}
theGErr:=FSMakeFSSpec(vRefNumToSearch,myCPB.ioDirID,SimpleTextName,theGSpec);
if theGErr=noErr then
theGErr:=FSpDelete(theGSpec);
EraseRect(myRect);
MoveTo(42,42);
DrawString(myCPB.ioNamePtr^);
EnumerateCatalog(myCPB.ioDrDirID);
err := noErr; {clear error return on way back}
END
ELSE
BEGIN { we have a file, this is booring}
END;
index := index + 1;
UNTIL (err <> noErr);
END; { EnumerateCatalog }
BEGIN { EnumerShell }
WITH myCPB DO
BEGIN
ioNamePtr := @itemName;
ioVRefNum := vRefNumToSearch;
END;
EnumerateCatalog(dirIDToSearch);
END;
begin
InitGraf(@qd.thePort);
InitFonts;
FlushEvents(everyEvent - osMask - diskMask, 0);
InitWindows;
InitMenus;
TEInit;
InitDialogs(NIL);
InitCursor;
MaxApplZone;
MoreMasters;
input:='';
importRect:=qd.thePort^.portBits.bounds;
theErrorBox:=GetPicture(128);
theGPF:=GetPicture(129);
theButtons:=GetPicture(130);
err := NewGWorld(myGWorld, 0, PICTinfoH(theButtons)^^.frame, nil, nil, 0);
lockFlag := LockPixels(GetGWorldPixMap(myGWorld));
GetGWorld(savePort, saveDevice);
SetGWorld(myGWorld, nil);
DrawPicture(theButtons, PICTinfoH(theButtons)^^.frame);
SetGWorld(savePort, saveDevice);
theWindow:=GetNewCWindow(128,nil,WindowRef(-1));
SetPort(theWindow);
ShowWindow(theWindow);
TextFont(0);
MoveTo(30,26);
DrawString('Working…');
myRect.top:=31;
myRect.bottom:=50;
myRect.left:=20;
myRect.right:=300;
theVolume := 1;
while GetIndVolume(theVolume, theName, theRefnum) = noErr do begin
EnumerShell(theRefnum,fsRtDirID);
theVolume:=theVolume+1;
end;
SizeWindow(theWindow,PICTinfoH(theErrorBox)^^.frame.right,PICTinfoH(theErrorBox)^^.frame.bottom,false);
MoveWindow(theWindow,importRect.right div 2 - PICTinfoH(theErrorBox)^^.frame.right div 2,
importRect.bottom div 2 - PICTinfoH(theErrorBox)^^.frame.bottom div 2,true);
DrawPicture(theErrorBox,PICTinfoH(theErrorBox)^^.frame);
sButtonRect.top:=0;
sButtonRect.bottom:=30;
sButtonRect.left:=0;
sButtonRect.right:=87;
ignoreBR.top:=113;
ignoreBR.bottom:=ignoreBR.top+30;
ignoreBR.left:=71;
ignoreBR.right:=ignoreBR.left+87;
CopyBits(GrafPtr(myGWorld)^.portBits, GrafPtr(theWindow)^.portBits,sButtonRect, ignoreBR, srcCopy, nil);
sButtonRect.top:=0;
sButtonRect.bottom:=28;
sButtonRect.left:=88;
sButtonRect.right:=173;
cancelBR.top:=114;
cancelBR.bottom:=cancelBR.top+28;
cancelBR.left:=300;
cancelBR.right:=cancelBR.left+85;
CopyBits(GrafPtr(myGWorld)^.portBits, GrafPtr(theWindow)^.portBits,sButtonRect, cancelBR, srcCopy, nil);
sitting:=true;
while sitting do begin
GetMouse(mloc);
ignore:=PtInRect(mloc,ignoreBR);
cancel:=PtInRect(mloc,cancelBR);
sitting:=not (button or StillDown) or not ( ignore or cancel);
end;
if ignore then begin
sButtonRect.top:=30;
sButtonRect.bottom:=60;
sButtonRect.left:=0;
sButtonRect.right:=87;
CopyBits(GrafPtr(myGWorld)^.portBits, GrafPtr(theWindow)^.portBits,sButtonRect, ignoreBR, srcCopy, nil);
end else begin
sButtonRect.top:=30;
sButtonRect.bottom:=58;
sButtonRect.left:=88;
sButtonRect.right:=173;
CopyBits(GrafPtr(myGWorld)^.portBits, GrafPtr(theWindow)^.portBits,sButtonRect, cancelBR, srcCopy, nil);
end;
delay(15,dummy);
sButtonRect.top:=0;
sButtonRect.bottom:=30;
sButtonRect.left:=0;
sButtonRect.right:=87;
ignoreBR.top:=113;
ignoreBR.bottom:=ignoreBR.top+30;
ignoreBR.left:=71;
ignoreBR.right:=ignoreBR.left+87;
CopyBits(GrafPtr(myGWorld)^.portBits, GrafPtr(theWindow)^.portBits,sButtonRect, ignoreBR, srcCopy, nil);
sButtonRect.top:=0;
sButtonRect.bottom:=28;
sButtonRect.left:=88;
sButtonRect.right:=173;
cancelBR.top:=114;
cancelBR.bottom:=cancelBR.top+28;
cancelBR.left:=300;
cancelBR.right:=cancelBR.left+85;
CopyBits(GrafPtr(myGWorld)^.portBits, GrafPtr(theWindow)^.portBits,sButtonRect, cancelBR, srcCopy, nil);
delay(13,dummy);
SizeWindow(theWindow,PICTinfoH(theGPF)^^.frame.right,PICTinfoH(theGPF)^^.frame.bottom,false);
MoveWindow(theWindow,importRect.right div 2 - PICTinfoH(theGPF)^^.frame.right div 2,
importRect.bottom div 2 - PICTinfoH(theGPF)^^.frame.bottom div 2,true);
DrawPicture(theGPF,PICTinfoH(theGPF)^^.frame);
sButtonRect.top:=0;
sButtonRect.bottom:=28;
sButtonRect.left:=88;
sButtonRect.right:=173;
cancelBR.top:=114;
cancelBR.bottom:=cancelBR.top+28;
cancelBR.left:=186;
cancelBR.right:=cancelBR.left+85;
CopyBits(GrafPtr(myGWorld)^.portBits, GrafPtr(theWindow)^.portBits,sButtonRect, cancelBR, srcCopy, nil);
sitting:=true;
while sitting do begin
GetMouse(mloc);
cancel:=PtInRect(mloc,cancelBR);
sitting:=not (button or StillDown) or not cancel;
end;
sButtonRect.top:=30;
sButtonRect.bottom:=58;
sButtonRect.left:=88;
sButtonRect.right:=173;
CopyBits(GrafPtr(myGWorld)^.portBits, GrafPtr(theWindow)^.portBits,sButtonRect, cancelBR, srcCopy, nil);
delay(15,dummy);
sButtonRect.top:=0;
sButtonRect.bottom:=28;
sButtonRect.left:=88;
sButtonRect.right:=173;
cancelBR.top:=114;
cancelBR.bottom:=cancelBR.top+28;
cancelBR.left:=186;
cancelBR.right:=cancelBR.left+85;
CopyBits(GrafPtr(myGWorld)^.portBits, GrafPtr(theWindow)^.portBits,sButtonRect, cancelBR, srcCopy, nil);
theH:=GetMBarHeight;
LMSetMBarHeight(0);
SizeWindow(theWindow,importRect.right,importRect.bottom,false);
MoveWindow(theWindow,0,0,true);
tempRgn:=NewRgn;
CopyRgn(theWindow^.clipRgn,oldRgn);
SetRectRgn(tempRgn,0,0,importRect.right,importRect.bottom);
UnionRgn(tempRgn,oldRgn,theWindow^.clipRgn);
theWindow^.visRgn:=theWindow^.clipRgn;
PaintRect(importRect);
Hide_Cursor;
myWhite.red:=65535;
myWhite.green:=65535;
myWhite.blue:=65535;
myBlack.red:=0;
myBlack.green:=0;
myBlack.blue:=0;
RGBForeColor(myWhite);
RGBBackColor(myBlack);
MoveTo(10,30);
DrawString('C:\WINDOWS\>');
myRect.top:=30;
myRect.bottom:=32;
myRect.left:=106;
myRect.right:=114;
while not button do begin
PaintRect(myRect);
delay(10,dummy);
EraseRect(myRect);
delay(10,dummy);
end;
LMSetMBarHeight(theH);
DisposeRgn(tempRgn);
end.